Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.*: fix lint issues of not having comments for exported funcs and vars along with any remaining issues and enable remaining disabled rules #7575

Merged
merged 12 commits into from
Sep 16, 2024

Conversation

purnesh42H
Copy link
Contributor

@purnesh42H purnesh42H commented Aug 30, 2024

Addresses: #7444

RELEASE NOTES: None

@purnesh42H purnesh42H mentioned this pull request Aug 30, 2024
13 tasks
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.73%. Comparing base (31ffeee) to head (5aefed2).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7575   +/-   ##
=======================================
  Coverage   81.73%   81.73%           
=======================================
  Files         361      361           
  Lines       27817    27816    -1     
=======================================
+ Hits        22735    22736    +1     
- Misses       3871     3872    +1     
+ Partials     1211     1208    -3     
Files with missing lines Coverage Δ
balancer/endpointsharding/endpointsharding.go 66.92% <ø> (ø)
balancer/pickfirst/pickfirst.go 83.73% <ø> (ø)
credentials/tls/certprovider/pemfile/builder.go 100.00% <ø> (ø)
internal/balancer/gracefulswitch/config.go 82.60% <ø> (ø)
internal/channelz/channel.go 79.80% <ø> (ø)
internal/channelz/server.go 90.69% <ø> (ø)
internal/channelz/socket.go 46.66% <ø> (ø)
internal/channelz/subchannel.go 96.00% <ø> (ø)
internal/channelz/trace.go 92.15% <ø> (ø)
internal/idle/idle.go 89.15% <ø> (ø)
... and 5 more

... and 8 files with indirect coverage changes

@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from a0d509d to bf84b2f Compare August 30, 2024 13:42
@purnesh42H purnesh42H added the Type: Documentation Documentation or examples label Aug 30, 2024
@purnesh42H purnesh42H added this to the 1.67 Release milestone Aug 30, 2024
balancer/endpointsharding/endpointsharding.go Outdated Show resolved Hide resolved
credentials/tls/certprovider/pemfile/builder.go Outdated Show resolved Hide resolved
internal/channelz/server.go Outdated Show resolved Hide resolved
internal/channelz/socket.go Outdated Show resolved Hide resolved
internal/channelz/socket.go Outdated Show resolved Hide resolved
Comment on lines +94 to +96
// A slice of traceEvent pointers representing the events recorded for
// this channel.
Events []*traceEvent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should this be unexported? Its type is unexported, which is an anti-pattern. It's probably unused outside this package would be my guess/hope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its being used in channelz/internal/protoconv

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not good. We should export traceEvent, then. If that's too hard to do in this PR, it's fine to leave it for now.

Copy link
Contributor Author

@purnesh42H purnesh42H Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this traceEvent is an internal representation of a single trace event. There is already an exported TraceEvent which is used in clientconn. We will have to give it a different name like TraceEventInternal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a very descriptive choice, but yes, some other name.

Is there any linter that covers unexported types being exposed outside a package, like this case? If so I would like to turn it on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no built-in rule but revive provides framework to write custom rules or we can ask revive contributors for this

internal/testutils/stats/test_metrics_recorder.go Outdated Show resolved Hide resolved
internal/transport/transport.go Outdated Show resolved Hide resolved
mem/buffers.go Outdated
@@ -119,20 +122,25 @@ func Copy(data []byte, pool BufferPool) Buffer {
return NewBuffer(buf, pool)
}

// ReadOnlyData returns the underlying byte slice of the Buffer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar as above. This type is unexported; these methods should not need comments.

Copy link

@alialobidm alialobidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arvindbr8 arvindbr8 assigned purnesh42H and unassigned arvindbr8 and dfawley Aug 30, 2024
@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from ea50b5f to 18b8820 Compare August 30, 2024 18:26
@purnesh42H purnesh42H requested a review from dfawley August 30, 2024 18:28
@purnesh42H purnesh42H assigned dfawley and unassigned purnesh42H Aug 30, 2024
@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from 18b8820 to 551ffd4 Compare August 31, 2024 09:33
mem/buffers.go Outdated
Comment on lines 217 to 218
// emptyBuffer is a Buffer implementation that represents an empty buffer. All
// methods are no-op implementations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

mem/buffers.go Outdated
type emptyBuffer struct{}

func (e emptyBuffer) ReadOnlyData() []byte {
return nil
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo this diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

mem/buffers.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned purnesh42H and unassigned dfawley Sep 3, 2024
@purnesh42H purnesh42H requested a review from dfawley September 3, 2024 19:22
@purnesh42H purnesh42H assigned dfawley and unassigned purnesh42H Sep 3, 2024
@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from 7ee93ab to c4692da Compare September 3, 2024 19:26
scripts/vet.sh Outdated Show resolved Hide resolved
@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from 767a0f0 to 8dad889 Compare September 5, 2024 04:25
@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from 8dad889 to 9f5e76e Compare September 6, 2024 15:48
@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch 2 times, most recently from db453a2 to a1861c3 Compare September 12, 2024 15:38
@purnesh42H purnesh42H requested a review from dfawley September 12, 2024 15:41
@purnesh42H purnesh42H assigned dfawley and unassigned purnesh42H Sep 12, 2024
@dfawley dfawley assigned purnesh42H and unassigned dfawley Sep 12, 2024
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, modulo a few comments and nits.

Comment on lines 19 to 21
// Binary client is an example client demonstrating use of advancedtls,
// to set up a secure gRPC client connection with various TLS authentication
// methods.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
// Binary client is an example client demonstrating use of advancedtls,
// to set up a secure gRPC client connection with various TLS authentication
// methods.
// Binary client is an example client demonstrating use of advancedtls, to set
// up a secure gRPC client connection with various TLS authentication methods.

func (c *Channel) SubChans() map[int64]string {
db.mu.RLock()
defer db.mu.RUnlock()
return copyMap(c.subChans)
}

// NestedChans returns a copy of the map of nested channels associated with the Channel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls wrap at 80 col

Suggested change
// NestedChans returns a copy of the map of nested channels associated with the Channel.
// NestedChans returns a copy of the map of nested channels associated with the
// Channel.

@@ -61,24 +65,29 @@ func (c *Channel) id() int64 {
return c.ID
}

// SubChans returns a copy of the map of sub-channels associated with the Channel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls wrap at 80 col:

Suggested change
// SubChans returns a copy of the map of sub-channels associated with the Channel.
// SubChans returns a copy of the map of sub-channels associated with the
// Channel.

Comment on lines 148 to 149
// String returns a string representation of the ChannelMetrics, including its state,
// target, and call metrics.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// String returns a string representation of the ChannelMetrics, including its state,
// target, and call metrics.
// String returns a string representation of the ChannelMetrics, including its
// state, target, and call metrics.

Comment on lines 156 to 157
// NewChannelMetricForTesting creates a new instance of ChannelMetrics with specified
// initial values for testing purposes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// NewChannelMetricForTesting creates a new instance of ChannelMetrics with specified
// initial values for testing purposes.
// NewChannelMetricForTesting creates a new instance of ChannelMetrics with
// specified initial values for testing purposes.

Comment on lines 172 to 174
// WaitForInt64Histo waits for an int histo metric to be recorded and
// verifies that the recorded metrics data matches the expected
// metricsDataWant.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WaitForInt64Histo waits for an int histo metric to be recorded and
// verifies that the recorded metrics data matches the expected
// metricsDataWant.
// WaitForInt64Histo waits for an int histo metric to be recorded and verifies
// that the recorded metrics data matches the expected metricsDataWant.

@@ -194,19 +197,19 @@ func (b *buffer) read(buf []byte) (int, Buffer) {
return n, b
}

// String returns a string representation of the buffer. May be used for
// debugging purposes.
func (b *buffer) String() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm, interesting that this one is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I was removing the docstrings for non exported structs

}
return status.Newf(codes.Internal, "grpc: Decompressor is not installed for grpc-encoding %q", recvCompress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it fixes one lingering superflous-else

[rule.indent-error-flow]
Disabled = true # TODO: Enable after existing issues are fixed


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix new line pls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines -28 to -35
[rule.exported]
Disabled = true # TODO: Enable after existing issues are fixed
[rule.redefines-builtin-id]
Disabled = true # TODO: Enable after existing issues are fixed
[rule.package-comments]
Disabled = true # TODO: Enable after existing issues are fixed
[rule.indent-error-flow]
Disabled = true # TODO: Enable after existing issues are fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep this PR focused on that change and address the other removals in a separate PR? This will make it easier to track the history of these changes in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine to just enable the remaining ones with this PR since at this time we are sure there are no more existing issues to be fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifying the PR title and merge commit to specify the PR also enable remaining disabled rules

@purnesh42H purnesh42H force-pushed the fix-revive-exported-lints branch from a1861c3 to 5aefed2 Compare September 13, 2024 19:27
@purnesh42H purnesh42H changed the title .*: fix revive lint issues of not having comments for exported funcs and vars .*: fix and enable revive lint issues of not having comments for exported funcs and vars along with any remaining issues Sep 14, 2024
@purnesh42H purnesh42H changed the title .*: fix and enable revive lint issues of not having comments for exported funcs and vars along with any remaining issues .*: fix lint issues of not having comments for exported funcs and vars along with any remaining issues and enable all rules Sep 14, 2024
@purnesh42H purnesh42H changed the title .*: fix lint issues of not having comments for exported funcs and vars along with any remaining issues and enable all rules .*: fix lint issues of not having comments for exported funcs and vars along with any remaining issues and enable remaining disabled rules Sep 16, 2024
@purnesh42H purnesh42H merged commit 04e78b0 into grpc:master Sep 16, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants